package com.hadoop.demo.mapreduce.lottery;

/**
 * =================================
 * <p>
 * Created by cjj on 2018/10/16.
 * <p>
 * 描述:
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class Spider {


    public static void main(String[] args) {
        String url = "http://www.baidu.com";
        String result = "";
        BufferedReader in = null;
        try {
            URL realUrl = new URL(url);

            URLConnection con = realUrl.openConnection();
            con.connect();
            in = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"));
            String line;
            while ((line = in.readLine()) != null) {

                result += line;
            }

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        System.out.println(result);
    }
}